<template>
	<view>
		<!-- 个人信息卡片 -->
		<view class="user-info">
			<view style="width: 80%;display: flex;justify-content: space-between;align-items: center;background-color: rgba(255,255,255,0.95);padding: 20rpx;border-radius: 20rpx;">
				<view style="width: 80%;display: flex;align-items: center;">
					<view style="width: 100rpx;height: 100rpx;margin-right: 30rpx;border-radius: 50%;overflow: hidden;">
						<image style="width: 100%;height: 100%;" :src="avatarPic(getUserinfo.avatar)" mode=""
							@click="userInfo()"></image>
					</view>
					<view>
						<text style="font-size: 30rpx;">{{getUserinfo.nickname}}</text>
					</view>
				</view>
				<view @click="myInfo()">
					<u-icon name="arrow-right" size="22"></u-icon>
				</view>
			</view>
		</view>
		<!-- 其他功能 -->
		<view style="margin: 20rpx;background-color: white;padding: 20rpx;">
			<u-grid :border="false" col="4">
				<u-grid-item v-for="(listItem,listIndex) in gridList" :key="listIndex" @click="gridClick(listIndex)">
					<u-icon :customStyle="{paddingTop:10+'rpx'}" :name="listItem.name" :size="22"
						color="#000000"></u-icon>
					<text style="font-size: 26rpx;margin-top: 10rpx;">{{listItem.title}}</text>
				</u-grid-item>
			</u-grid>

		</view>
	</view>
</template>

<script>
	import {
		mapGetters,
		mapActions
	} from 'vuex'
	export default {
		data() {
			return {
				title: '我的',
				gridList: [{
					name: 'plus-circle',
					title: '我的发布'
				}, {
					name: 'star',
					title: '我的收藏'
				}, {
					name: 'question-circle',
					title: '帮助中心'
				}, {
					name: 'info-circle',
					title: '关于我们'
				}],
				// avatar:''
			}
		},
		onShow() {
			console.log("当前状态Login", this.getIsLogin);
			if (!this.getIsLogin) {
				//未登录
				uni.navigateTo({
					url: '/pages/login/login'
				})
			} else {

			}
		},
		computed: {
			...mapGetters(['getUserinfo', 'getIsLogin'])
		},
		methods: {
			myInfo() {
				uni.navigateTo({
					url: '/pages/myInfo/myInfo' // 个人资料
				})
			},
			// 头像处理
			avatarPic(pic) {
				if (pic) {
					return pic.includes('http') ? this.getUserinfo.avatar : 'http://localhost:8080' + this.getUserinfo
						.avatar
				} else {
					return pic
				}

			},
			// 卡片点击
			gridClick(listIndex) {
				if (listIndex == 0) {
					uni.navigateTo({
						url: '/pages/myPublish/myPublish'
					})
				}
				if (listIndex == 1) {
					uni.navigateTo({
						url: '/pages/myCollect/myCollect'
					})
				}
				if (listIndex == 2) {
					uni.navigateTo({
						url: '/pages/helpCenter/helpCenter'
					})
				}
				if (listIndex == 3) {
					uni.navigateTo({
						url: '/pages/aboutUs/aboutUs'
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.user-info {
		display: flex;
		justify-content: center;
		align-items: center;
		text-align: center;
		height: 150px;
		background: linear-gradient(#66a6ff, #89f7fe);


	}
</style>